package com.blog.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.blog.entity.Blog;
import com.blog.service.BlogService;

@Controller
/*@RequestMapping(value="/blog")*/
public class BlogController {
	//注入BlogService
	@Autowired
	private BlogService blogService;
	/**
	 * 查询blog到页面上
	 * @return
	 */
	@RequestMapping(value="/findAllBlog.do",method=RequestMethod.GET)
	public String findAllBlog(HttpServletRequest request) {
		List<Blog> list=blogService.findAllBlog();
		request.setAttribute("list", list);
		return "blog";
	}
	/**
	 * 查看博客
	 */
	@RequestMapping(value="/check.do",method=RequestMethod.GET)
	public String check(Blog blog,HttpServletRequest request) {
		Blog bloginfo=blogService.findById(blog.getId());
		request.setAttribute("bloginfo", bloginfo);
		return "blogInfo";
	}
	
	
}
